package com.pdd.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * @创建时间: 2018/8/14 - 8:20
 * @编写人员: 丷教皇
 * @文件描述:
 */
@EnableSwagger2
@Configuration
@EnableWebMvc
//@ComponentScan(basePackages = {"com.pdd.controller"})
public class SwaggerConfig {

    /**
     * 创建一个平台
     * @return api
     */
    @Bean
    public Docket api(){
        Docket docket = new Docket(DocumentationType.SWAGGER_2);

        return docket.select()
                .apis(RequestHandlerSelectors.any())
                .paths(PathSelectors.any())
                .build()
                .apiInfo(apiInfo());
    }

    /**
     * 配置平台信息
     * @return 平台信息
     */
    private ApiInfo apiInfo(){
        return new ApiInfoBuilder()
                .title("PDD-API")
                .description("拼多多API测试平台")
                .license("这是平台的许可信息")
                .version("v1.0")
                .contact("这里是联系方式")
                .build();
    }

}
